""" 
esp32 有4个定时器: 0-3

"""
from machine import Pin
from machine import Timer

led1 = Pin(15, Pin.OUT)
led1_state = 0


def timer0_irq(timer0):
    global led1_state
    led1_state = not led1_state
    led1.value(led1_state)
    print("set led {}".format(led1_state))


count = 0


def timer1_irq(timer1):
    global count
    print("count = {}".format(count))
    count += 1


if __name__ == "__main__":
    timer0 = Timer(0)
    timer0.init(period=1000, mode=Timer.PERIODIC, callback=timer0_irq)

    timer1 = Timer(1)
    timer1.init(period=1000, mode=Timer.PERIODIC, callback=timer1_irq)

    while True:
        pass
